package com.lagou.server;

import com.lagou.service.UserServiceImpl;
import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(value = "com.lagou")
public class ServerBootstrap implements Watcher {

    public static void main(String[] args) throws InterruptedException {
        SpringApplication.run(ServerBootstrap.class, args);
        UserServiceImpl.startServer("127.0.0.1", 8991);
        //注册到zookeeper
        ZkClient zkClient = new ZkClient("127.0.0.1:2181");

//         zkClient.createPersistent("/127.0.0.1/8991",true);
//         zkClient.createEphemeral("/127.0.0.1");
         zkClient.createEphemeral("/127.0.0.1/8991",true);
         System.out.println("success create znode.");



    }


    @Override
    public void process(WatchedEvent watchedEvent) {

    }
}
